#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

const int N = 110;
const double eps = 1e-8;

double a[N][N];
int n, m;

int gauss() {
    int r, c;
    for (r = 0, c = 0; c < n; c++) {

        // 1. 找到最大值
        int t = r;
        for (int i = r; i < n; i++) {
            if (fabs(a[i][c]) > fabs(a[t][c]))
                t = i;
        }

        if (fabs(a[t][c]) < eps) continue;

        // 2. 交换到首行
        for (int i = c; i < m; i++) swap(a[r][i], a[t][i]);

        // 3. 本行首列置为1
        for (int i = m - 1; i >= c; i--) a[r][i] /= a[r][c];

        // 4. 下面的行首列置为0
        for (int i = r + 1; i < n; i++) {
            if (fabs(a[i][c]) < eps) continue;
            for (int j = m - 1; j >= c; j--) {
                a[i][j] -= a[i][c] * a[r][j]; // - 首航本列 * i, r首列商
            }
        }

        r++;
    }
    return r;
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf("%lf", &a[i][j]);
            // printf("%.2lf\n", a[i][j]);
        }
    }

    int t = gauss();
    printf("%d\n", t);
    return 0;
}
